<?php
use yii\helpers\Url;
?>
<div class="tpl-login">
    <div class="tpl-login-content">
        <div class="tpl-login-logo">

        </div>
        <div style="text-align: center;font-size: 25px;color: #b5b5b5">
            高淳垃圾回收系统
        </div>


        <form class="am-form tpl-form-line-form">
            <div class="am-form-group">
                <input type="text" class="tpl-form-input" id="username" placeholder="请输入账号">

            </div>

            <div class="am-form-group">
                <input type="password" class="tpl-form-input" id="password" placeholder="请输入密码">

            </div>

            <div class="am-form-group">

                <button type="button" id="login" class="am-btn am-btn-primary  am-btn-block tpl-btn-bg-color-success  tpl-login-btn">登录</button>

            </div>
        </form>
    </div>
</div>
</div>
<script>
    $("#login").click(function(){
        var csrf=$('meta[name="csrf-token"]').attr("content");
        var username= $("#username").val();
        var password=$("#password").val();
        if(username==''){
            alert("用户名不能为空！");
            return ;
        }
        if(password==''){
            alert("密码不能为空！");
            return ;
        }


        $.ajax({
            url:"<?=Url::to(['site/sign-up'])?>",
            data:'_csrf='+csrf+"&username="+username+"&password="+password,
            type:'post',
            dataType:'json',
            success:function(data){
                if(data.status){
                    window.location.href="<?=Url::to(['site/index'])?>";
                }else{
                    alert(data.msg);
                }
            },
            error:function(){
                alert("系统繁忙");
            }
        })
    })
</script>